<template>
	<button class="bi-share-button" open-type="share" @click="handleClick">
		<slot></slot>
	</button>
</template>

<script>
import { setShareData } from '@/utils/share.js'

export default {
	name: 'BiShareButton',
	props: {
		disabled: {
			type: Boolean,
			default: false
		},
		shareTitle: {
			type: String
		},
		sharePath: {
			type: String
		},
		shareCover: {
			type: String
		}
	},
	methods: {
		handleClick () {
			if (this.disabled) {
				return
			}
			setShareData({
				title: this.shareTitle,
				imageUrl: this.shareCover,
				path: this.sharePath
			})
		}
	}
}
</script>

<style lang="less">
button.bi-share-button{
	padding: 0;
	min-width: auto;
	border: none;
	outline: 0;
	background-color: transparent;
	line-height: 1;
	font-size: 14px;
	&:after {
		display: none;
	}
}
</style>